Table of Contents Previous Section

Loading Application Resources

WebScript supplies a special method for loading external resources into your application: the WOApplication method pathForResource:ofType:. This method takes a path and the resource file's extension as arguments:

id filePath = [WOApp pathForResource:@"DataFiles/MyData" ofType:@"string"];

where DataFiles is a directory (which in this case is immediately under the application directory), and MyData.string is a file in that directory.

Once you load a resource you can use it within your application, for example to initialize another object:

id aString = [NSString stringWithContentsOfFile:filePath];

There are no restrictions on the type of file you load into your application using pathForResource:ofType:--- you can use it to load images, sound files, data files, and so on.

Table of Contents Next Section